using DistributedGISA, Plots

# create state constraint
X = [@interval(-5,5), @interval(-5,5), @interval(-5,5)]

# number of division in each dimension
d = 64

# create the intervals in each dimension
ds = DiscreteSpace(X,[d,d,d])

# full system model
f(x,u) = (2.0*x[1] + u[1], x[1] + 2.0*x[2], x[2] + 2.0*x[3])

# input constraint
u = [@interval(-1,1)]

# initial approximation of the control invariant set
Rk = [[i,j,k] for i in 1:d for j in 1:d for k in 1:d]


# create digraph
G = create_graph(Rk,ds,u,f)
# select nonleaving cells
nlc = select_nonleaving_cells(G)
# update the control invariant set
Rk = Rk[nlc]
# create cells for processing
bxs = create_boxes(Rk,ds)

# find convexhull of the cells
arr = ConvexHullArray(bxs)
# project onto respective dimension
R1c = Projection(arr,[1,2])
R2c = Projection(arr,[2,3])
R3c = Projection(arr,[1,3])

println("Done!!!")